package com.ar4j.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Defines the behavior of a native SQL method on an ActiveRecord 
 */
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NamedQueryMethod {

  /**
   * @return the name of the SQL query to run, the record's context must have a 
   * named query source when the method is executed
   */
  String queryName();
  
  /**
   * @return property names of the parameters defined in the method arguments
   */
  String[] value() default { };
  
  /**
   * @return default parameter name/value pairs to be used
   */
  DefaultParameter[] defaultParameters() default { };
  
  /**
   * @return true if the native SQL method is an update (INSERT/UPDATE/DELETE) 
   * as opposed to a lookup (SELECT)
   */
  boolean update() default false;
  
}
